#pragma once
#include <WinGDI.h>

#include "afxext.h"
#include "PlayerButton.h"
#include "afxwin.h"
#include "afxcmn.h"

#include <memory>
#include "errorInfo.h"
#include "smartCOM.h"

#include "ProSliderCtrl.h"

namespace DSP
{
    template<class T>
    class DSplayer;
    class simpleGraph;
	class Ivideo;
	class Ievent;
}

class CPlayerDialog : public CDialog
{
	std::shared_ptr<DSP::DSplayer<DSP::simpleGraph>> m_Player;
	DSP::Ivideo *m_Video;

	PlayerButton m_ButtonPlay;
	PlayerButton m_ButtonNext;
	PlayerButton m_ButtonPrevious;
	PlayerButton m_ButtonStop;
	PlayerButton m_ButtonVolume;

	CEdit m_PlayTime;

	CStatic m_Background;
	CStatic m_VideoWindow;

	CProSliderCtrl m_PlaySlider;
	CProSliderCtrl m_VolumeSlider;

	CString m_MaxTime;

	int	m_SliderMax;
	int m_VolumePos;
	int m_CurVolume;

	long m_WinW;
	long m_WinH;

	double m_AspectRatio;

	bool m_HourMode;
	bool m_IsVideo;
	bool m_IsFullScreen;
	bool m_IsVolume;

	DECLARE_DYNAMIC(CPlayerDialog)
	virtual void DoDataExchange(CDataExchange* pDX);
	DECLARE_MESSAGE_MAP()

	CString GetTimeString(int sec);
	CString SecToString(int sec);
	void SetMaxTimeString(int sec);
	void FullScreen(void);

public:
	enum PlayStatus{NO_FILE, FILE_PLAY, FILE_PAUSE, FILE_STOP};
	int m_PlayStatus;
	int m_CurPos;

	bool m_IsHTML;

	CString m_FileName;

	CPlayerDialog(CWnd* pParent = NULL);
	virtual ~CPlayerDialog();

	enum { IDD = IDD_PLAYER_DIALOG };

	virtual BOOL OnInitDialog();

	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnBnClickedButtonPlay();
	afx_msg void OnBnClickedButtonStop();
	afx_msg void OnBnClickedButtonMute();
	afx_msg void OnBnClickedButtonNext();
	afx_msg void OnBnClickedButtonPrevious();
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg void OnDropFiles(HDROP hDropInfo);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg LRESULT OnBitmapSliderMoving(WPARAM wParam, LPARAM lParam);

	void StartPlaying(void);
	void StopPlaying(void);
};
